package com.dkm.biz.gl.repository.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.dkm.base.core.helper.SpringHelper;
import com.dkm.base.db.persistence.dao.IQueryDao;
import com.dkm.biz.gl.domain.EavSet;
import com.dkm.biz.gl.persistence.dao.EavSetQueryDao;
import com.dkm.biz.gl.persistence.entity.EavSetPo;
import com.dkm.biz.gl.repository.EavSetRepository;
import com.dkm.biz.repository.AbstractRepository;

/**
 * 对象功能:属性集 Repository接口的实现类
 * 开发公司:SKG.COM
 * 开发人员:Yuki
 * 创建时间:2014-12-13 16:44:11
 */
@Repository
public class EavSetRepositoryImpl extends AbstractRepository<String, EavSetPo,EavSet> implements EavSetRepository{
	  
	@Resource
	private  EavSetQueryDao eavSetQueryDao;

	public EavSet newInstance() {
		EavSetPo po = new EavSetPo();
		EavSet eavSet = SpringHelper.getBean(EavSet.class);
		eavSet.setData(po);
		return eavSet;
	}

	public EavSet newInstance(EavSetPo po) {
		EavSet eavSet = SpringHelper.getBean(EavSet.class);
		eavSet.setData(po);
		return eavSet;
	} 
	
	@Override
	protected IQueryDao<String, EavSetPo> getQueryDao() {
		return eavSetQueryDao;
	}

	/**
	 * 根据setKey获取属性集
	 * @param setKey
	 * @return EavSetPo
	 */
	@Override
	public EavSetPo findBySetKey(String setKey) {
		 Map<String,Object> setParam = new HashMap<String,Object>();
		 setParam.put("setKey", setKey);
		 return eavSetQueryDao.getByKey("findBySetKey", setParam);
		}
	public List<EavSetPo>	 findByEntityType(String entityType){
		 Map<String,Object> param = new HashMap<String,Object>();
		 param.put("entityType", entityType);
		 return eavSetQueryDao.findByKey("findByEntityType", param);
	}
}
